package com.simple.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.simple.entity.CodeResult;
import com.simple.entity.MailBean;
import com.simple.service.SendMailService;
import com.simple.utils.EncryptionUtils;

/**
 * 邮箱测试
 */
@Controller
public class Test {
	
	@Autowired
	SendMailService sendMailService;
	
	@RequestMapping("/sendMailTest.html")
	@ResponseBody
	public CodeResult test(HttpServletRequest request) {
		MailBean mailBean=new MailBean();
		mailBean.setReceiver("1570868334@qq.com");
		mailBean.setSubject("测试邮件");
		Map<String, Object> map=new HashMap<String, Object>();
		String encriotionMail=EncryptionUtils.encryptBase64("1570868334@qq.com","daliang9527");
		String activationUrl="http://"+request.getServerName()+":"+request.getServerPort()+"/activation.html?sign="+encriotionMail;
		map.put("url", activationUrl);
		mailBean.setMap(map);
		sendMailService.sendMail(mailBean,false);
		return CodeResult.success();
	}
	
}
